function getBoxList() {
    let boxList = {};
    $.ajax({
        async: false,
        type: "get",//type可以为post也可以为get
        url: "http://localhost:3000/expert",
        dataType: "json",//这里要注意如果后台返回的数据不是json格式，那么就会进入到error:function(data){}中
        success: function (data) {
            // console.log(data)
            // boxList=data;
            boxList = data
            // alert(data)
        },
        error: function (data) {
        }
    });
    return boxList;
}

let data = getBoxList();


let btn = document.getElementsByClassName("btn");
btn[2].style.backgroundColor = "#FE6C00";


document.getElementsByClassName("bgm")[0].innerHTML = `
    <img src="./assets/img/expert.png">
    `

// 专家介绍--------------------------------------

document.getElementsByClassName('expertList')[0].innerHTML = getExpertList(data.supportList);

function getExpertList(data) {
    let supportList = ``;
    data.forEach(function (item, i) {
        if (i < 3) {
            supportList += `
            <div class="expertListItem">
                <div class="expertListItemImg"><img src='${item.imgSrc}'></div>
                 <div class="expertContent">
                   <div class="expertTitle">${item.title}</div>
                        <div class="expertSolid"></div>
                        <span class="expertDetail">${item.content}</span>
                </div>
            </div>
            `
        }
    });
    return supportList;
};


// 智能开掘------------------------------------------
document.getElementsByClassName("intelligenceBox")[0].innerHTML = getIntelligence(data.expert);

function getIntelligence(expert) {
    // console.log(expert);
    let list = `
 <div class="intelligence">
    <div class="intelligenceContent">
         <div class="intelligenceContentTitle">${expert[0].intelligence.title}</div>
         <div class="intelligenceContentAddress">${expert[0].intelligence.address}</div>
         <div class="intelligenceContentDetail">${expert[0].intelligence.content}</div>
    </div>
    <div class="intelligenceImg"><img src="${expert[0].intelligence.imgSrc}"></div>
    </div>
    <div class="intelligenceItem">
    </div>
 `
    return list;
}

document.getElementsByClassName("intelligenceItem")[0].innerHTML = getIntelligenceList(data.expert[0].intelligence.list);

function getIntelligenceList(data) {
    let list = ``;
// console.log(data);
    data.forEach(function (item, index) {

        list += ` <div class="intelligenceList">
    <div class="intelligenceContentTitle">${item.title}</div>
    <div class="intelligenceContentDetail">${item.content}</div>
</div>`
    })
    return list;
}


document.getElementsByClassName('policy')[0].innerHTML = getSupportList(data.policy);

function getSupportList(data) {
    let supportList = ``;
    data.forEach(function (item, i) {
        if (i < 4) {
            supportList += `
            <div class="policyListItem">
                <div class="policyListItemImg"><img src='${item.imgSrc}'></div>
                 <div class="policyContent">
                   <div class="policyTitle">${item.title}</div>
                        <div class="policyDetail">${item.content}</div>
                        <div>
                        <span class="policyAuthor">作者：${item.author}</span>
                        <span class="policyAuthor">时间：${item.date}</span>
                        </div>
                </div>
            </div>
            `
        }
    });
    return supportList;
};
